package com.mymorningroutine;
import android.app.*;
import android.os.*;
import java.util.*;
import java.io.*;
import android.widget.*;
import com.mymorningroutine.utils.*;
import android.util.*;
import android.preference.*;
import android.content.*;

public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener
{

	
	

	private Map<String, String> settings;

	private TextView textView;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO: Implement this method
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.settings);
		
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
		sharedPreferences.registerOnSharedPreferenceChangeListener(this);
		Map<String,?> mapPref = sharedPreferences.getAll();
		for(Map.Entry<String,?> entry : mapPref.entrySet()){
			Preference pref = findPreference(entry.getKey());
			updateSummary(pref);
		}
		
	}

	private void updateSummary(Preference pref)
	{
		
		// TODO: Implement this method
		if (pref instanceof ListPreference) {
			ListPreference listPref = (ListPreference) pref;
			pref.setSummary(listPref.getEntry());
		} else if(pref instanceof EditTextPreference){
			EditTextPreference editPref = (EditTextPreference) pref;
			pref.setSummary(editPref.getText());
		} else if(pref instanceof CheckBoxPreference){
			CheckBoxPreference checkPref = (CheckBoxPreference) pref;
		}
		
	}
	
	

	public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
		Preference pref = findPreference(key);
		updateSummary(pref);
	}
	
	
	
}
